//
//  AssociatedWithIViewTableViewCell.m
//  安好
//
//  Created by rlp on 14-12-17.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "AssociatedWithIViewTableViewCell.h"

@implementation AssociatedWithIViewTableViewCell

- (void)awakeFromNib {
    // Initialization code

    

    

    
    
    self.contentLabel.backgroundColor = [UIColor clearColor];

//    self.bottomViewSub.backgroundColor = [ClassMethodsViewController colorWithHexString:LINE_BACKGROUNDCOLOR_16];
    
//    self.bottomView.backgroundColor = [UIColor clearColor];

    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setNoticeData:(NoticeData *)noticeData{
    _noticeData = noticeData;

    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    self.titleView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, ((kScreenWidth == 414)?52*1.2:52))];
    self.titleView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleView];
    self.frame = CGRectMake(0, 0, kScreenWidth, self.titleView.frame.size.height);
    UserModel *userm = [[UserManager shareInstance]getUserInfo];
    
    self.titleImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 10, (((kScreenWidth == 414)?30*1.2:30)), ((kScreenWidth == 414)?30*1.2:30))];
    [self.titleImageView setImageURLStr:[NSString stringWithFormat:@"%@",noticeData.avatar] placeholder:[UIImage imageNamed:@"默认头像"]];
    self.titleImageView.layer.cornerRadius = 3.f;
    self.titleImageView.layer.masksToBounds = YES;
    [self.titleView addSubview:self.titleImageView];
    
    
    self.titleTime = [[UILabel alloc]initWithFrame:CGRectZero];
    self.titleTime.text = [DateConversion dataWithSecondToNow:noticeData.dateline];
    self.titleTime.font = [UIFont systemFontOfSize:LABEL_FONT_SIZE_TIME];
    self.titleTime.textColor = TITLE_ARTICLE_TEXTFONT_COLOR;
    [self.titleTime sizeToFit];
    self.titleTime.frame = CGRectMake(kScreenWidth-self.titleTime.frame.size.width-15, self.titleImageView.frame.origin.y, self.titleTime.frame.size.width, self.titleTime.frame.size.height);
    [self.titleView addSubview:self.titleTime];
    
    
    NSInteger titleNameW =kScreenWidth-(self.titleImageView.frame.size.width+self.titleImageView.frame.origin.x+10)-(self.titleTime.frame.size.width+15);
    
    self.titleName = [[UILabel alloc]initWithFrame:CGRectMake(self.titleImageView.frame.size.width+self.titleImageView.frame.origin.x+10, self.titleImageView.frame.origin.y, titleNameW, self.titleImageView.frame.size.height)];
    self.titleName.text = noticeData.username;
    self.titleName.font = [UIFont systemFontOfSize:TITLE_TEXTLABEL_FOUNT_SIZE];
    self.titleName.textColor = TITLE_ARTICLE_TEXTFONT_COLOR;
    [self.titleView addSubview:self.titleName];

    
    
    
    
    
    
    
    
    NSString *contentLabelStr =@"";
    NSString *bottomLabelStr =@"";
    NSString *smLabelStr =@"";

    

    
    if (noticeData.summary.length==0) {//回复的回复
        contentLabelStr =[NSString stringWithFormat:@"%@",noticeData.message];
        
        
        
        
        bottomLabelStr =[NSString stringWithFormat:@"%@:%@",noticeData.recvusername,noticeData.subject];
    }else{//回帖 和 点赞
        if ([noticeData.type integerValue] == 2) { //点赞
            contentLabelStr =[NSString stringWithFormat:@"%@",noticeData.message];
            bottomLabelStr =[NSString stringWithFormat:@"%@",noticeData.summary];
            
            smLabelStr = [NSString stringWithFormat:@"%@",noticeData.subject];
            
        }else if([noticeData.type integerValue] == 1){//回复帖子
            contentLabelStr =[NSString stringWithFormat:@"%@",noticeData.message];
//            bottomLabelStr =[NSString stringWithFormat:@"%@:%@ %@",userm.username,notificationPmlistData.subject,notificationPmlistData.summary];
            bottomLabelStr =[NSString stringWithFormat:@"%@",noticeData.summary];
            
            smLabelStr = [NSString stringWithFormat:@"%@",noticeData.subject];
        }
    
    }

    
//    if ([notificationPmlistData type] == 1){
//        contentLabelStr =[NSString stringWithFormat:@"%@回复:%@",notificationPmlistData.username,notificationPmlistData.subject];
//        
//        
//        
//        
//    }else  if ([notificationPmlistData type] == 2){
//        contentLabelStr =[NSString stringWithFormat:@"%@攒了你的帖子",notificationPmlistData.username];
//        
//        
//        
//        
//
//    }
    
    
    
    UILabel *contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, self.titleView.height+5, kScreenWidth-15*2, 0) text:contentLabelStr font:[UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_13] textColor:TITLE_ARTICLE_CONTENTFONT_COLOR backgroundColor:[UIColor clearColor] numberOfLines:0 lineSpacing:5];

    self.contentLabel = contentLabel;
    [self.contentView addSubview:self.contentLabel];

    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height+self.contentLabel.frame.size.height+self.contentLabel.origin.y+10);
    
    /**
     三角
     */
    
    
    
    
    self.sanjiao = [[Sanjiao alloc]initWithFrame:CGRectMake(30, self.contentLabel.frame.origin.y+self.contentLabel.frame.size.height+5, 15, 15)];
    self.sanjiao.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.sanjiao];
    
    

    self.bottomViewSub = [[UIView alloc]initWithFrame:CGRectMake(15, self.sanjiao.frame.origin.y+self.sanjiao.frame.size.height-10, kScreenWidth-15*2, 0)];

    
    

    
    
    
    
    if (smLabelStr.length==0) {
        UILabel *bottomLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, 8, self.bottomViewSub.frame.size.width-8*2, 0) text:bottomLabelStr font:[UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_13] textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor] numberOfLines:0 lineSpacing:5];
        self.bottomViewSub.frame = CGRectMake(15,  self.sanjiao.frame.origin.y+self.sanjiao.frame.size.height-10,kScreenWidth-15*2, bottomLabel.size.height+8*2);
        [self.contentView addSubview:self.bottomViewSub];
        
        
        self.bottomViewSub.backgroundColor = [ClassMethodsViewController colorWithHexString:TABBAR_BACKGROUNDCOLOR_16];
        self.bottomLabel = bottomLabel;
        
        [self.bottomViewSub addSubview:self.bottomLabel];
        
        self.frame =CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.bottomViewSub.frame.size.height+self.bottomViewSub.frame.origin.y+5);

    }else{
        UILabel *smLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, 8, self.bottomViewSub.frame.size.width-8*2, 0) text:smLabelStr font:[UIFont systemFontOfSize:LABEL_FONT_SIZE_TITLE] textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor] numberOfLines:0 lineSpacing:5];

        UILabel *bottomLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, smLabel.frame.size.height+smLabel.frame.origin.y+5, self.bottomViewSub.frame.size.width-8*2, 0) text:bottomLabelStr font:[UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_13] textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor] numberOfLines:0 lineSpacing:5];

        
        
        
        self.bottomViewSub.frame = CGRectMake(15,  self.sanjiao.frame.origin.y+self.sanjiao.frame.size.height-10,kScreenWidth-15*2, bottomLabel.size.height+8*2+smLabel.frame.size.height);
        [self.contentView addSubview:self.bottomViewSub];
        
        
        self.bottomViewSub.backgroundColor = [ClassMethodsViewController colorWithHexString:LINE_BACKGROUNDCOLOR_16];
        self.bottomLabel = bottomLabel;
        
        [self.bottomViewSub addSubview:self.bottomLabel];
        [self.bottomViewSub addSubview:smLabel];
        self.frame =CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.bottomViewSub.frame.size.height+self.bottomViewSub.frame.origin.y+5);

    }
    

    
    

    
    

//
//    
//    self.bottomView = [[UIView alloc]init];
//    self.bottomView.frame = CGRectMake(0, self.contentLabel.frame.origin.y+self.contentLabel.frame.size.height+5, kScreenWidth, self.bottomViewSub.frame.size.height+10);
//    
//
//
//    
//    [self.contentView addSubview:self.bottomView ];
//    [self.bottomView addSubview:self.sanjiao];
//    [self.bottomView addSubview:self.bottomViewSub];
//    [self.bottomViewSub addSubview:self.bottomLabel];
    
    
    
    /**
     *  线条的处理
     */
    
    UIView *bottomLineView = [[UIView alloc]initWithFrame:CGRectMake(5, self.frame.size.height-1,kScreenWidth-5, 0.5)];
    
    bottomLineView.backgroundColor = [ClassMethodsViewController colorWithHexString:LINE_BACKGROUNDCOLOR_16];
    [self.contentView addSubview:bottomLineView];



    

}

@end
